using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using WebapiTemplate.Domain.Entity;
using WebapiTemplate.Infrastructure.Persistence.DomainConfiguration.Base;

namespace WebapiTemplate.Infrastructure.Persistence.DomainConfiguration
{
    /// <summary>
    /// 设置表字段，并继承基础字段的设置类
    /// </summary>

    public class AuditLogConfiguration : BaseEntityConfiguration<AuditLog>
    {
        public override void Configure(EntityTypeBuilder<AuditLog> builder)
        {
            base.Configure(builder); //using Microsoft.EntityFrameworkCore;

            //设置表名
            builder.ToTable("app_auditlog"); //using Microsoft.EntityFrameworkCore;

            builder
                .Property(x => x.UserInfo)
                .HasColumnName("user_info")
                .HasMaxLength(2000)
                .HasColumnOrder(1); //using Microsoft.EntityFrameworkCore;
            builder
                .Property(x => x.ServiceName)
                .HasColumnName("servicename")
                .HasMaxLength(2000)
                .HasColumnOrder(2); 
            builder
                .Property(x => x.MethodName)
                .HasColumnName("method_name")
                .HasMaxLength(2000)
                .HasColumnOrder(3); 
            builder
                .Property(x => x.Parameters)
                .HasColumnName("parameters")
                .HasMaxLength(2000)
                .HasColumnOrder(4); 
            builder
                .Property(x => x.ReturnValue)
                .HasColumnName("return_value")
                .HasMaxLength(2000000000)
                .HasColumnOrder(5); //为了能装下文件字节流，哭了0.0
            builder
                .Property(x => x.ExecutionTime)
                .HasColumnName("execution_time")
                .HasMaxLength(2000)
                .HasColumnOrder(6); 
            builder
                .Property(x => x.ExecutionDuration)
                .HasColumnName("execution_duration")
                .HasMaxLength(2000)
                .HasColumnOrder(7); 
            builder
                .Property(x => x.ClientName)
                .HasColumnName("client_name")
                .HasMaxLength(2000)
                .HasColumnOrder(8); 
            builder
                .Property(x => x.ClientIpAddress)
                .HasColumnName("clientIp_address")
                .HasMaxLength(2000)
                .HasColumnOrder(9); 
            builder
                .Property(x => x.BrowserInfo)
                .HasColumnName("browser_info")
                .HasMaxLength(2000)
                .HasColumnOrder(10); 
            builder
                .Property(x => x.CustomData)
                .HasColumnName("custom_data")
                .HasMaxLength(2000)
                .HasColumnOrder(11); 
            builder
                .Property(x => x.Exception)
                .HasColumnName("exception")
                .HasMaxLength(2000)
                .HasColumnOrder(12); 
        }
    }
}
